package mm.test;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class MockDispatcher implements RequestDispatcher {
	
	private String url;

	public MockDispatcher(String url) {
		this.url=url;
	}

	public void forward(ServletRequest request, ServletResponse response)
			throws ServletException, IOException {
		MockRequest req=(MockRequest)request;
		MockResponse res=(MockResponse)response;
		req.setServletPath(url);
		MockResponse newRes = req.submit();
		res.mergeFrom(newRes);
	}

	public void include(ServletRequest arg0, ServletResponse arg1)
			throws ServletException, IOException {
		throw new java.lang.UnsupportedOperationException();
	}

}
